package com.paireach.bw.http;

import com.paireach.bw.utils.LogUtil;
import com.paireach.bw.utils.Md5;

import java.util.HashMap;

/**
 * Created by ${cqc} on 2017/2/3.
 */

public class UserRequest {

    //登陆
    public static void passwordLogin_app(String username, String password, boolean deviceRoot, int sdkVersion, String androidID,
                                         String macAddress, String manufacturer, String model, boolean is4G, boolean wifiEnabled,
                                         String networkOperatorName, String imei, String imsi, int phoneType,
                                         String simOperatorName, String phoneStatus, String simCardNo) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", username);
        try {
            map.put("driverPwd", Md5.getStringMD5(password));
            LogUtil.d("UserRequest", "MD5=" + Md5.getStringMD5(password));
        } catch (Exception e) {
            map.put("driverPwd", "");
        }
        //
        map.put("deviceRoot", "" + String.valueOf(deviceRoot));
        map.put("sdkVersion", "" + String.valueOf(sdkVersion));
        map.put("androidID", "" + androidID);
        map.put("macAddress", "" + macAddress);
        map.put("manufacturer", "" + manufacturer);
        map.put("model", "" + model);
        map.put("is4G", "" + String.valueOf(is4G));
        map.put("wifiEnabled", "" + String.valueOf(wifiEnabled));
        map.put("networkOperatorName", "" + networkOperatorName);
        map.put("imei", "" + imei);
        map.put("imsi", "" + imsi);//为null无法登陆
        map.put("phoneType", "" + String.valueOf(phoneType));
        map.put("simOperatorName", "" + simOperatorName);
        map.put("phoneStatus", "" + phoneStatus);
        map.put("simCardNo", "" + simCardNo);

        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loginForDriver.a", map, RequestTag.USER_LOGIN);
    }


    public static void changePassword(String phone, String password) {
        HashMap<String, String> map = new HashMap<>();
        map.put("mobile", phone);
        try {
            map.put("newPwd", Md5.getStringMD5(password));
        } catch (Exception e) {
            map.put("newPwd", "");
        }
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "changeDriverPwd.a", map, RequestTag.CHANGE_PASSWORD);
    }

    // TODO: 2017/2/7
    public void commitUserInfo(String phone, String password) {
        HashMap<String, String> map = new HashMap<>();
        map.put("mobile", phone);
        map.put("mobile", phone);

        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "changeDriverPwd.a", map, RequestTag.COMMIT_USER_INFO);
    }
}
